/**
 * @author TrinhNX
 * @start_date	: 2015/04/21
 * @end_date 	:
 * I like those simple mathematical, remind me about 6th grade :)
 */
public class Euler028 {

	public static void main(String[] args) {
		// First one
		// Top right: 9, 25, 49 .... 1001*1001
		final long start = System.currentTimeMillis();
		System.out.println(2 * sumSquare(2, 1001, 1) + 1 - 250* 251 - 250 * 1000 + 500 - 250 * 501);
		System.out.println("End after: " + (System.currentTimeMillis() - start));
		// 669 171 001 
	}

	/**
	 * sum from [start - end with delimeter value ]
	 * @author		: TrinhNX
	 * @param start
	 * @param end
	 * @param delimiter
	 * @return
	 * @start_date	: 2015/04/21
	 * @end_date	:
	 */
	private static long sumSquare(final int start, final int end, final int delimiter) {
		long sum = 0;
		for (int i = start; i <= end; i = i + delimiter) {
			sum += i * i;
		}
		return sum;
	}
}
